import {postStream} from '@/api/Http'

export interface PalmAnalysisParams {
  imageUrl: string
}

export class PalmReadingApi {
  static async analyzePalm(params: PalmAnalysisParams): Promise<ReadableStreamDefaultReader<Uint8Array>> {
    const response = await postStream('/entertainment/palmReading/analyze', params)

    if (!response.ok) {
      throw new Error(`Analysis failed: ${response.statusText}`)
    }

    if (!response.body) {
      throw new Error('No response body')
    }

    return response.body.getReader()
  }
}
